{include file="common/top" /}
<div style="padding: 20px;background: #ffffff;" >
	<form class="layui-form " action="">
	<div class="layui-form-item">
		<label class="layui-form-label">赔付编号：</label>
		<div class="layui-col-xs4">
			<input type="text" name="code" value="{$num}" readonly="readonly" lay-verify="required" autocomplete="off" class="layui-input">
		</div>
		<label class="layui-form-label">*赔付类别：</label>
		<div class="layui-col-xs4">
			<select name="type" lay-verify="required" autocomplete="off" lay-filter="type">
				<option value="" >请选择</option>
				<option value="1" >客户备款</option>
				<option value="2" >账户充值</option>
				<option value="3" >客户退款</option>
	        </select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">*媒介人员：</label>
		<div class="layui-col-xs4">
			<select name="media_id" lay-verify="required" lay-search="" autocomplete="off">
				<option value="" >请选择</option>
				{volist name="user_list" id='mj'}
					<option value="{$mj.id}" >{$mj.username}</option>
				{/volist}
	        </select>
		</div>
		<label class="layui-form-label">*运营人员：</label>
		<div class="layui-col-xs4">
			<select name="operate_id" lay-verify="required" lay-search="" autocomplete="off">
				<option value="" >请选择</option>
				{volist name="user_list" id='yy'}
					<option value="{$yy.id}" >{$yy.username}</option>
				{/volist}
	        </select>
		</div>
	</div>
	<div class="layui-form-item ">
		<label class="layui-form-label">*渠道名称：</label>
		<div class="layui-col-xs4">
			<select name="channel_id"  lay-search="" lay-filter="channel" autocomplete="off" >
				<option value="">直接选择或搜索选择</option>
				{volist name="channel_list" id='qd'}
					<option value="{$qd.id}" >{$qd.name}</option>
				{/volist}
	        </select>
		</div>
		<label class="layui-form-label">*账户名称：</label>
		<div class="layui-col-xs4">
			<select name="op_account_id" id='accselect' lay-search="" autocomplete="off" >
				
	        </select>
		</div>
	</div>
	<div class="layui-form-item pay4" style='display:none'>
		<label class="layui-form-label">*客户名称：</label>
		<div class="layui-col-xs4">
			<select name="customer_id" lay-search="" autocomplete="off" >
				<option value="">直接选择或搜索选择</option>
				{volist name="customer_list" id='cu'}
					<option value="{$cu.id}" >{$cu.name}</option>
				{/volist}
	        </select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">返点(%)：</label>
		<div class="layui-col-xs4">
			<input type="text" name="rebate"  autocomplete="off" placeholder="请输入返点百分比" class="layui-input fd">
		</div>
		<label class="layui-form-label">服务费(%)：</label>
		<div class="layui-col-xs4">
			<input type="text" name="service_pay"  autocomplete="off" placeholder="请输入服务费百分比" class="layui-input fwf">
		</div>
	</div>
	<div class="layui-form-item pay1" style='display:none'>
		<label class="layui-form-label">*赔付金额：</label>
		<div class="layui-col-xs4">
			<input type="text" name='amount' autocomplete="off" placeholder="请输入充值金额" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item pay2" style='display:none'>
		<label class="layui-form-label">*赔付账户币：</label>
		<div class="layui-col-xs4">
			<input type="text" name="currency" autocomplete="off"  class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">*备注：</label>
		<div class="layui-col-xs8">
			<textarea name="note" autocomplete="off" placeholder="请输入详细备注" class="layui-textarea"></textarea>
		</div>
	</div>
	<hr />
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn"  lay-submit="" lay-filter="demo1">添加</button>
		</div>
	</div>
	
	</form>
	
</div>
{include file="common/footer" /}

<script>
	var $,form,layer
	layui.use(['form', 'layedit', 'laydate'], function(){
		  form = layui.form ,layer = layui.layer,$ = layui.jquery;
		  
		  //监听提交
		  form.on('submit(demo1)', function(data){
			var articleFrom = data.field;
			layer.load(1, { shade : [ 0.5, '#676a6c' ] });
			$.post("{:url('add_paid')}?t=json",articleFrom,function(data){
				layer.closeAll();
				if (data['code'] == 1) {
					var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index1); //再执行关闭 
					
				} else {
					layer.msg(data['msg'], { icon : 5 });
				}
			});
			
			return false;
		  });
		//下拉菜单事件
		form.on('select(channel)', function (data) {
			layer.load(1, { shade : [ 0.5, '#676a6c' ] }); 
			$.post("{:url('Media/get_acc_info')}",{channel_id:data.value},function(da){
				layer.closeAll();
				  if(da['code'] == 1){
					  	$("#accselect").html('');
				 		$("#accselect").append('<option value="">直接选择或搜索选择</option>')
				 		$.each(da.data,function(k,v){
				 			$("#accselect").append("<option value="+v.id+">名称："+v.name+"，资质："+v.cert+"</option>");
				 		});
						form.render();
				  }else{
					  $("#accselect").empty();
					  form.render("select");
					  layer.msg(da['msg'], { icon : 5 });
				  }
			})
			
		})
		form.on('select(type)', function (data) {
			if(data.value == 1 || data.value == 3){
				$('.pay1').css("display",'block');
				$('.pay2').css("display",'none');
				$('.pay4').css("display",'block');
			}else if(data.value == 2){
				$('.pay1').css("display",'none');
				$('.pay2').css("display",'block');
				$('.pay4').css("display",'none');
			}else{
				$('.pay1').css("display",'none');
				$('.pay2').css("display",'none');
				$('.pay4').css("display",'none');
			}
		})
	});

	
	
	
</script>
